// @ts-ignore
import auth from './directives/auth.js'
// @ts-ignore
import role from './directives/role.js'
// @ts-ignore
import time from './directives/time.js'
// @ts-ignore
import copy from './directives/copy.js'
// @ts-ignore
import toFixed from "./directives/toFixed.js"

import * as elIcons from '@element-plus/icons-vue'

import scTable from "@/components/scTable/index.vue";
import scFormTable from "@/components/scFormTable/index.vue";
import scUpload from './components/scUpload/index.vue'
import scUploadMultiple from './components/scUpload/multiple.vue'

import errorHandler from './utils/errorHandler'

export default {
    install(app: any) {
        app.directive('auth', auth)
        app.directive('role', role)
        app.directive('time', time)
        app.directive('copy', copy)
        app.directive('toFixed', toFixed)

        //关闭async-validator全局控制台警告
        // @ts-ignore
        window.ASYNC_VALIDATOR_NO_WARNING = 1

        //统一注册el-icon图标
        for(let icon in elIcons){
            // @ts-ignore
            app.component(`ElIcon${icon}`, elIcons[icon])
        }

        //注册全局组件
        app.component('scTable', scTable);
        app.component('scFormTable', scFormTable);
        app.component('scUpload', scUpload);
        app.component('scUploadMultiple', scUploadMultiple);

        //全局代码错误捕捉
        app.config.errorHandler = errorHandler
    }
}
